/**
 * 
 */

window.onload = function () {
		var winWidth=$(window).width();
		if(winWidth > 1440){
			FullScreenBackground('#bgimg');
			$('#bgimg').removeClass('item');
		}else{
			FullScreenBackground('#bgimg_s');
			$('#bgimg_s').removeClass('item');
		}
		
	}
	$(window).resize(function() {
		var winWidth=$(window).width();	
		console.log(winWidth);
		
		if(winWidth > 1440){				
		 window.location="";
		}else{ 		
			FullScreenBackground('#bgimg_s');
		}
	});
	function FullScreenBackground(theItem,theBox){
	var winWidth=$(window).width();
	var winHeight=$(window).height();
	var imageWidth=$(theItem).width();
	var imageHeight=$(theItem).height();
	var picHeight = imageHeight / imageWidth;
	var picWidth = imageWidth / imageHeight;

		$('.down').css('width',$('.up').width());
	if ((winHeight / winWidth) < picHeight) {
		$(theItem).css("width",winWidth);
		$(theItem).css("height",picHeight*winWidth);
	} else {
		$(theItem).css("height",winHeight);
		$(theItem).css("width",picWidth*winHeight);
	};
	$(theItem).css("margin-left",winWidth / 2 - $(theItem).width() / 2);
	$(theItem).css("margin-top",winHeight / 2 - $(theItem).height() / 2);
	}
	
	/* Javascript Principal */
	
$(function(){
	/* masonry*/
	 var $container = $('.thumbsContainer');

	    $container.imagesLoaded(function () {
	        $container.masonry({
	            itemSelector: '.post-box',
	            columnWidth: '.post-box',
	            transitionDuration: 0
	        });
	    });
	   
	/* end of masonry */
	 /* date picker */
	var nowTemp = new Date();
	var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
	 $('#year').datepicker(
			 {
				 format:"dd-mm-yyyy",
				  onRender: function(date) {
				    return date.valueOf() < now.valueOf() ? 'disabled' : '';
				  }
				});
	 $('#date').datepicker(
			 {
				 format:"dd-mm-yyyy",
				  onRender: function(date) {
				    return date.valueOf() < now.valueOf() ? 'disabled' : '';
				  }
				});
	/* end of date picker */
})

function clearDate(){
		$('#year').val('');
}